package com.studysystem.repository;

import com.studysystem.entity.CourseProgress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface CourseProgressRepository extends JpaRepository<CourseProgress, Long> {
    Optional<CourseProgress> findByUserIdAndCourseId(Long userId, Long courseId);
    List<CourseProgress> findByUserId(Long userId);
    List<CourseProgress> findByCourseId(Long courseId);
    
    @Query("SELECT cp FROM CourseProgress cp WHERE cp.user.id = ?1 AND cp.isCompleted = true")
    List<CourseProgress> findCompletedCoursesByUserId(Long userId);
    
    @Query("SELECT cp FROM CourseProgress cp WHERE cp.user.id = ?1 AND cp.isCompleted = false")
    List<CourseProgress> findInProgressCoursesByUserId(Long userId);
} 